package scenetracer.core;

import scenetracer.math.Matrix4;
import scenetracer.math.Point3;
import scenetracer.math.Vector3;

public class Ray {
	private Point3 origin;
	private Vector3 direction;
	private float tmin = 0;
	private float tmax = Float.POSITIVE_INFINITY;
	
	public Ray(Point3 origin, Vector3 direction){
		this.setOrigin(origin);
		this.setDirection(direction);
	}

	public void setOrigin(Point3 origin) {
		this.origin = origin;
	}

	public Point3 getOrigin() {
		return origin;
	}

	public void setDirection(Vector3 direction) {
		this.direction = direction;
	}

	public Vector3 getDirection() {
		return direction;
	}

	public float getMax() {
		return tmax;
	}

	public void setMax(float tmax) {
		this.tmax = tmax;
	}

	public float getMin() {
		return tmin;
	}

	public void transform(Matrix4 cameraToWorld) {
		origin = cameraToWorld.transformP(origin);
		direction = cameraToWorld.transformV(direction);
	}

}
